package org.ycx.doc.service.impl;

import org.ycx.common.annotation.BaseService;
import org.ycx.common.base.BaseServiceImpl;
import org.ycx.doc.dao.enums.ModuleType;
import org.ycx.doc.dao.mapper.IDocModuleMapper;
import org.ycx.doc.dao.mapper.IDocModulePageMapper;
import org.ycx.doc.dao.model.DocModule;
import org.ycx.doc.dao.model.DocModulePage;
import org.ycx.doc.dao.model.DocModulePageExample;
import org.ycx.doc.service.IDocModulePageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * DocModulePageService实现
 * Created by yang on 2017-08-30 17:02:41.
 */
@Service
@Transactional
@BaseService
public class DocModulePageServiceImpl extends BaseServiceImpl<IDocModulePageMapper, DocModulePage, DocModulePageExample> implements IDocModulePageService {

    private static Logger _log = LoggerFactory.getLogger (DocModulePageServiceImpl.class);

    @Autowired
    IDocModulePageMapper mapper;

    @Autowired
    IDocModuleMapper docModuleMapper;

    @Override
    public int addPage(DocModule bean, String content) {
        bean.setmVersion (0);
        bean.setModuleType (ModuleType.OnePage.getType ());
        int res = this.docModuleMapper.insert (bean);
        DocModulePage page = new DocModulePage ();
        page.setContent (content);
        page.setModuleId (bean.getModuleId ());
        return this.mapper.insertSelective (page);
    }
}